/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package planspiel.panels;

import java.awt.Image;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.image.BufferedImage;

import javax.imageio.ImageIO;
import javax.swing.GroupLayout;
import javax.swing.ImageIcon;
import javax.swing.JButton;
import javax.swing.JLabel;
import javax.swing.JPanel;

import planspiel.PlanspielView;

/**
 *
 * @author Administrator
 */
public class TitleScreen extends JPanel implements MyAbstractPanel {
    
    /**
	 * 
	 */
	private static final long serialVersionUID = 1996137495661655914L;
	private PlanspielView planSpiel = null;
    
    /**
     * 
     */
    public TitleScreen() {
    }
    
    /**
     * 
     * @param planSpiel
     */
    public void setPlanspielView(PlanspielView planSpiel){
        this.planSpiel = planSpiel;
    }
        
    /**
     * 
     */
    public void paintScreen() {
        try {
            GroupLayout layout = new GroupLayout(this);
            layout.setAutoCreateGaps(true);
            this.setLayout(layout);
            BufferedImage image = new BufferedImage(1000, 800, BufferedImage.TYPE_INT_RGB);
            image = ImageIO.read(this.getClass().getResourceAsStream("/planspiel/resources/TitleScreen.jpg"));
            JLabel welcomeImage = new JLabel(new ImageIcon(image.getScaledInstance(800, 600, Image.SCALE_SMOOTH)));
            JButton startTheGame = new JButton("This is the Title Screen - start the game");
            
            startTheGame.addActionListener(new ActionListener() {

                public void actionPerformed(ActionEvent e) {
                    planSpiel.screen2_welcomeScreen();
                }
            });

            layout.setHorizontalGroup(
                layout.createParallelGroup(GroupLayout.Alignment.TRAILING)
                    .addComponent(welcomeImage)
                    .addComponent(startTheGame, GroupLayout.DEFAULT_SIZE, GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
            );
            layout.setVerticalGroup(
                layout.createSequentialGroup()
                    .addComponent(welcomeImage)
                    .addComponent(startTheGame, GroupLayout.DEFAULT_SIZE, GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
            );
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
    
}
